import Vue from "vue";
// 对歌曲时间进行处理
Vue.filter('formatDateTime', function (time) {
  let minutes = parseInt(time / 60); // 获取时长分钟
  let seconds = parseInt(time % 60); // 获取时长秒数
  seconds = seconds < 10 ? '0' + seconds : seconds // 秒
  minutes = minutes < 10 ? '0' + minutes : minutes
  return minutes + ':' + seconds
})
/* 歌曲时长的过滤器 */
Vue.filter('timeFormat', function (time) {
  if (typeof time === 'undefined') return 0
  var date = new Date(time)
  var minute = date.getMinutes()
  var second = date.getSeconds()
  minute = minute < 10 ? ('0' + minute) : minute
  second = second < 10 ? ('0' + second) : second
  return minute + ':' + second
})
/* 时间的过滤器 */
Vue.filter('dateFormat', function (time) {
  if (typeof time === 'undefined') return 0
  var date = new Date(time);
  var y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? ('0' + m) : m;
  var d = date.getDate();
  d = d < 10 ? ('0' + d) : d;
  return y + '-' + m + '-' + d
})
// 数量的过滤器
Vue.filter('changeNum', function (num) {
  if (num >= 100000000) {
    return (num / 100000000).toFixed(1) + '亿'
  } else if (num > 10000) {
    return (num / 10000).toFixed(1) + '万'
  } else {
    return num
  }
})

